package cn.stazxr.core.filter;

import cn.stazxr.core.XssHttpServletRequestWrapper;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;

import java.io.IOException;

/**
 * @author talentestors
 * @version 1.0
 * @since 2025.11.06
 **/
public class XssFilter implements Filter {
	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		// 这个过滤器的作用，仅仅是将原始的request进行一个包装，通过子类去处理xss攻击
		chain.doFilter(new XssHttpServletRequestWrapper((HttpServletRequest) request), response);
	}
}
